import {Events, IonicPage, Navbar, NavController, NavParams} from "ionic-angular";
import {Component, ViewChild} from "@angular/core";
import {DialogProvider} from "@providers/dialog";
import {Util} from "@providers/util";
import {NativeProvider} from "@providers/natives/native";

/**
 * 师傅明细界面
 */
@IonicPage()
@Component({
  selector: 'page-manager-contact-detail',
  templateUrl: 'manager-contact-detail.html',
})
export class ManagerContactDetailPage {
  contact: any = this.navParams.data;
  @ViewChild('tel') tel: any;
  @ViewChild(Navbar) navbar: Navbar;

  constructor(public navCtrl: NavController,
              public navParams: NavParams,
              private dialog: DialogProvider,
              private events: Events,
              private native: NativeProvider) {
  }

  ionViewDidLoad() {
    Util.replaceBackButtonEvent(this.navbar, this.navCtrl, this.events);
    if (this.contact.FWLX && this.contact.FWLX == 1) {
      this.contact.RYLX = '服务人员';
    } else if (this.contact.SHLX && this.contact.SHLX == 1) {
      this.contact.RYLX = '送货人员';
    } else if (this.contact.BYLX && this.contact.BYLX == 1) {
      this.contact.RYLX = '搬运人员';
    }
  }

  push(page: string, data?: any) {
    this.navCtrl.push(page, data);
  }

  //打电话
  call() {
    this.dialog.showConfirm(() => {
      this.native.call(this.contact.LXDH);
    }, '是否拨打电话：' + this.contact.LXDH);
  }

}
